<template>
  <div class="head">
    <div class="head_left">
      <i class="iconfont icon-chushi"></i>
      <span>爱小厨后台管理</span>
    </div>
    <div class="head_right">
      <i class="iconfont icon-lingdang-xianxing"></i>
      <div>
        <img :src="data.userAvtardata" alt />
        <p>{{username}}</p>
      </div>
      <i class="iconfont icon-xiangxia"></i>
    </div>
  </div>
</template>

<script>
import { onMounted, reactive, ref } from "vue";
import axios from "axios";
export default {
  setup() {
    const username = sessionStorage.getItem("username") || "";
    const data = reactive({
      userAvtardata: "",
    });
    // 请求头像
    function avtar() {
      axios
        .get(`http://120.76.246.120:4455/Sapi/userAvtar?username=${username}`)
        .then((res) => {
          // 头像链接
          data.userAvtardata = res.data[0].useravtar;
        });
    }
    avtar();
    return {
      data,
      username,
    };
  },
};
</script>

<style lang="scss" scoped>
// $width: 100%;
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
li {
  list-style: none;
}
.head {
  padding: 0 35px;
  width: 100%;
  height: 50px;
  display: flex;
  justify-content: space-between;
  position: fixed;
  top: 0;
  z-index: 999;
  background-color: #fff;
  .head_left {
    width: 200px;
    text-align: left;
    line-height: 50px;
    display: flex;
    justify-content: space-evenly;
    font-size: 20px;
    font-weight: bold;
    > i {
      font-size: 30px;
    }
  }
  > .head_right {
    width: 300px;
    height: 50px;
    display: flex;
    justify-content: space-evenly;
    line-height: 50px;
    font-size: 20px;
    > div {
      width: 100px;
      height: 30px;
      display: flex;
      font-size: 16px;
      > img {
        margin: 10px 10px 0 0;
        width: 30px;
        height: 30px;
        border-radius: 50%;
      }
    }
    > img {
      width: 50px;
      height: 50px;
    }
    > .select {
      outline: none;
      width: 10px;
      height: 10px;
    }
    > i:nth-of-type(2) {
      transition: all 0.5s linear;
    }
    > i:nth-of-type(2):hover {
      transform: rotate(180deg);
      transition: all 0.5s linear;
    }
  }
}
</style>